// pages/tongji/tongji.js
import * as echarts from '../../lib/ec-canvas/echarts';
var util= require('../../utils/util.js');
var Promise = require('../../utils/es6_promise.js')
const app = getApp()

 let promiseWeek = [];
 let promiseMonth = [];
 let promiseCountMonth = [];
 let promiseCountweek = [];

Page({

  /**
   * 页面的初始数据
   */
  data: {
    week_date:[
      {date:""},
      {date:""},
      {date:""},
      {date:""},
      {date:""},
      {date:""},
      {date:""},
  ],
  weeksums:[0,0,0,0,0,0,0],//一周中每一天的总时间
  WeekSum:0,//一周 周的总时间
  week_xlist:['周一', '周二', '周三', '周四', '周五', '周六', '周日'],

  monthsums:[],//[0,0,0,0,0,0,0]一月中每一天的总时间
  MonthSum:0,//一月的总时间
  averageMonthSum:0,
  search_month_date:[],//2021/05/08
  month_xlist:[],//月折线图的横坐05/08，没有年份

  ec: {lazyLoad:true},
  today:"",
  b_color1: "#7E80AC", color1: "#FFF",
  b_color2: "#FFF", color2: "#7E80AC",
    
  month_week:1,//1表示是按week来查看，0表示按month来查看
  weeks:[
    {week:"本周",monday_date:"",state:1},//monday_date表示这一周的周一所对应的日期：2021/05/02 这样子
  ],
  months:[
    {month:"本月",yearmonth:"",state:1},
  ],
  arrDaojishi:[
    {daojishid:"",daojishiname:"4444",  alltime:1,  baifenbi:0},
  ],
  // arrThings:[
  //   {id:0,djs_id:0,title:"考研高数", time:50,color:"#775D79"},
  //],

  },

  getdayNum(month,year){//判断月份的天数
    var days;
    if(month==1||month==3||month==5||month==7||month==8||month==10||month==12){
      days=31
    }
    else if(month==4||month==6||month==9||month==11||month==10){
      days=30
    }
    else if(month==2&&year%400==0&&year%4!=0){//不是闰年
    days=28
    }
    else{//闰年的二月
      days=29
    }
    return days;
  },
  getMondayDateInt(date){//获得所需要的周一 的时间戳   
    var day =  date.getDay();//获取传过来的日期是星期几
    if(day==0){day=7}
    // 2、接下来找到本周的周一对应的时间戳
    var mondayInt = (date.getTime()) -24*60*60*1000*(day-1);
    return mondayInt;
  },
  getDateFormat1(date,type){//获得2021/05 或2021/05/01格式的日期
    var Y = date.getFullYear() + '/';
    var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1);
    var D = (date.getDate()) < 10 ? '/0'+(date.getDate()) : '/'+date.getDate();
    var ym = Y+M;
    var ymd = Y+M+D;
    var md = M+D;
    if(type==2) return ym;
    else if(type==3) return ymd;
    else return md;
  },
  getWeekBaifenbi(){
    for(var i=0;i<this.data.arrDaojishi.length;i++){
      var temp1 = 'arrDaojishi['+i+'].baifenbi'
      var temp2 = 'arrDaojishi['+i+'].alltime'
      var alltime1 = parseInt(this.data.arrDaojishi[i].alltime/60)
      var baifenbi = (parseInt(this.data.arrDaojishi[i].alltime/60)*100)/(this.data.WeekSum);
      this.setData({
        [temp1]:baifenbi,
        [temp2]:alltime1
      })
    }
  },
  getMonthBaifenbi(){
    for(var i=0;i<this.data.arrDaojishi.length;i++){
      var temp1 = 'arrDaojishi['+i+'].baifenbi'
      var temp2 = 'arrDaojishi['+i+'].alltime'
      var alltime1 = parseInt(this.data.arrDaojishi[i].alltime/60)
      var baifenbi = (parseInt(this.data.arrDaojishi[i].alltime/60)*100)/(this.data.MonthSum);
      this.setData({
        [temp1]:baifenbi,
        [temp2]:alltime1
      })
    }
  },
  getOneWeekDaySum(week_date){//统计一周中的每天的时长 赋值给weeksums数组并且获得 七天的时长总和WeekSum
    //console.log("getOneWeekDaySum收到的week_date:",week_date)
    this.setData({
      WeekSum:0,
      arrDaojishi:[]
    })
    //在根据这个范围的日期，来获取这一周中的每天用户的计时时长总和
    for(var i=0;i<7;i++){
      promiseWeek.push(new Promise((resolve,reject)=>{
        var Sum=0;
        var qq = i;
        wx.cloud.callFunction({
          name:"get_tongji_jishi",
          data:{
            date:week_date[i].date
          },
          success:res=>{ 
            var daysData = res.result.data;           
            if(daysData.length!=0){//有数据的话
              //console.log("这一天的日期：",res.result.data[0].date)   
              //折线图的数据处理
              for(var k=0;k<daysData.length;k++){//统计这一天的时长
                Sum +=daysData[k].trueduration;
                //柱状图的处理
                var hasDaojishi=0;//默认表示不存在
                for(var q=0;q<this.data.arrDaojishi.length;q++){//检查已有的daojishid是否已经存在
                  if(daysData[k].daojishid==this.data.arrDaojishi[q].daojishid){//如果找到和已存在的id一直的话
                    hasDaojishi=1;
                    var alltimeTemp = this.data.arrDaojishi[q].alltime + daysData[k].trueduration
                    var temp1 = 'arrDaojishi['+q+'].alltime'
                    this.setData({
                      [temp1]:alltimeTemp
                    })
                    break;
                  }
                }
                if(hasDaojishi==0){//是不存在的，则把它添加进去
                  var leng=this.data.arrDaojishi.length
                  var alltimeTemp = (daysData[k].trueduration); 
                  var temp1 = 'arrDaojishi['+leng+'].alltime'
                  var temp2 = 'arrDaojishi['+leng+'].daojishiname'
                  var temp3 = 'arrDaojishi['+leng+'].daojishid'
                  this.setData({
                    [temp1]:alltimeTemp,
                    [temp2]:daysData[k].daojishiname,
                    [temp3]:daysData[k].daojishid
                  })
                }
              }
              this.data.WeekSum+=parseInt(Sum/60);
              this.data.weeksums[qq]=parseInt(Sum/60) ;
              this.setData({
                weeksums:this.data.weeksums,
                WeekSum:this.data.WeekSum
              })
              //console.log(i,this.data.arrDaojishi)
            }
            else{
              Sum=0;
              this.data.WeekSum+=parseInt(Sum/60);
              this.data.weeksums[qq]=parseInt(Sum/60) ;
              this.setData({
                weeksums:this.data.weeksums,
                WeekSum:this.data.WeekSum
              }) 

            }
          resolve(res)  
        },
          fail:res=>{
            //reject(res)
            console.log("错误")
          }
        });

      }))
    }

  },
  getOneMonthDaySum( days){//统计一个月的每天的时长，赋值给monthsums 
    console.log("getOneMonthDaySum收到的month_date",this.data.search_month_date)
    this.setData({
      MonthSum:0,
      arrDaojishi:[]
    })
    for(var i=0;i<days;i++){
      promiseMonth.push(new Promise((resolve,reject)=>{
        var Sum=0;
        var qq = i;
        wx.cloud.callFunction({
          name:"get_tongji_jishi",
          data:{
            date:this.data.search_month_date[i]
          },
          success:res=>{ 
            var daysData = res.result.data;           
            if(daysData.length!=0){
              console.log("这一天的日期：",res.result.data[0].date)   
              for(var k=0;k<daysData.length;k++){//统计这一天的时长
                Sum +=daysData[k].trueduration
                var hasDaojishi=0;//默认表示不存在
                for(var q=0;q<this.data.arrDaojishi.length;q++){//检查已有的daojishid是否已经存在
                  if(daysData[k].daojishid==this.data.arrDaojishi[q].daojishid){//如果找到和已存在的id一直的话
                    hasDaojishi=1;
                    var alltimeTemp = this.data.arrDaojishi[q].alltime + daysData[k].trueduration
                    var temp1 = 'arrDaojishi['+q+'].alltime'
                    this.setData({
                      [temp1]:alltimeTemp
                    })
                    break;
                  }
                }
                if(hasDaojishi==0){//是不存在的，则把它添加进去
                  var leng=this.data.arrDaojishi.length
                  var alltimeTemp = (daysData[k].trueduration); 
                  var temp1 = 'arrDaojishi['+leng+'].alltime'
                  var temp2 = 'arrDaojishi['+leng+'].daojishiname'
                  var temp3 = 'arrDaojishi['+leng+'].daojishid'
                  this.setData({
                    [temp1]:alltimeTemp,
                    [temp2]:daysData[k].daojishiname,
                    [temp3]:daysData[k].daojishid
                  })
                }
              }             
              this.data.MonthSum+=parseInt(Sum/60);
              this.data.monthsums[qq]=parseInt(Sum/60) ;
              this.setData({
                monthsums:this.data.monthsums,
                MonthSum:this.data.MonthSum,
                averageMonthSum:this.data.MonthSum/days
              })
            //  console.log(Sum,qq); 
            }
            else{
              this.data.monthsums[qq]=0;
              this.setData({
                monthsums:this.data.monthsums,
              })
            }
            resolve(res); 
          },
          fail:res=>{
            //reject(res)
            console.log("错误")
          }
        })
      }))    
    }
  },

  getNowWeekData(){ //读取本周的计时信息 
  var dayNow =  new Date();
  var mondayInt = this.getMondayDateInt(dayNow);
    // 3、之后在将后面的各个星期的对应的日期都赋值上
    for(var i=0;i<7;i++){
      var dayInt = mondayInt+ 24*60*60*1000*i;//往后一天
      var date = new Date(dayInt);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
      var date = this.getDateFormat1(date,3);
      //console.log(date)
      var temp = 'week_date['+i+'].date'
      this.setData({//记录下当天的日期和星期
        [temp]:date
      })
    }
    this.getOneWeekDaySum(this.data.week_date);
  },

  getNowMonthData(){//读取本月的计时信息
      // 1、今天的日期：   
      var dayNow =  new Date()//获取今天的日期 
      // 2、接下来找到本月的一号对应的时间戳
      dayNow.setDate(1);//获取当月的第一天 console.log(dayNow)
      var firstdayInt = dayNow.getTime();//得到月初的时间戳  
      // 3、判断这个月有多少天 days
      var days=this.getdayNum(dayNow.getMonth()+1,dayNow.getFullYear());//获得月份的天数
      for(var i=0;i<days;i++){
        var dayInt = firstdayInt+ 24*60*60*1000*i;//往后一天
        var date = new Date(dayInt);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
        var date1 = this.getDateFormat1(date,3);
        var date2 = this.getDateFormat1(date,1);
        var temp = 'search_month_date['+i+']';
        var x_month_date = 'month_xlist['+i+']'
        this.setData({
          [temp]:date1,
          [x_month_date]:date2
        })
      }
      //4、计算每一天的总和
      this.getOneMonthDaySum(days)
      // console.log(this.data.month_xlist)
      // console.log(this.data.search_month_date)
  },

  getmanyweeks(){//函数功能：获取用户使用本小程序到当天有多少个周  并赋值到weeks中
    //1、得到用户初次登录的日期年月日 以及星期几
    var logindate=app.globalData.userInfo[0].logindate;
    //var logindate="2021/03/10";
    console.log("用户首次登录的日期：",logindate)
    var loginyear = parseInt(logindate.substring(0, 4));
    var loginmonth = parseInt(logindate.substring(5, 7));
    var logindate = parseInt(logindate.substring(8,10))
    //console.log(loginyear,loginmonth,logindate)
    var daytemp =  new Date()//获取今天的日期 
    daytemp.setFullYear(loginyear);
    daytemp.setMonth(loginmonth-1);
    daytemp.setDate(logindate);
    //console.log(daytemp.getDay())
    var login_Xingqi = daytemp.getDay();//获得首次登录是星期几

    //2、然后从本周开始，判断用户第一次登录的日期是否在这个周之内
    var dayNow =  new Date()//获取今天的日期 
    var now_Xingqi = dayNow.getDay();//获取当前是星期几
    if(login_Xingqi==0)login_Xingqi=7; //星期天的时候.getTime()函数返回的是0，转化为7，计算才不会出错。
    if(now_Xingqi==0)now_Xingqi=7;
    //获得这周的星期一的日期赋值给week[0].monday_date
    var now_mondayInt = dayNow.getTime()-((now_Xingqi-1)*60*60*24*1000)
    var now_monday = new Date(now_mondayInt);
    var ymd= this.getDateFormat1(now_monday,3)
   // console.log("这周周一是：",ymd);
    var temp1 = 'weeks['+0+'].monday_date'
    this.setData({
      [temp1]:ymd
    })
   // console.log(this.data.weeks)
    //3、判断有多少个周
    var weekNum;
    if(login_Xingqi==now_Xingqi) { //如果星期数相同，直接设置时分秒都是000，然后,getTime()获取时间戳相减获得总的天数相差，然后再除以7*60*60*24一周的时间就可以得到有多少个周了
      daytemp.setHours(0);
      daytemp.setSeconds(0);
      daytemp.setMinutes(0);
      dayNow.setHours(0);
      dayNow.setSeconds(0);
      dayNow.setMinutes(0);
      weekNum = ((dayNow.getTime()-daytemp.getTime())/(7*60*60*24*1000))+1//得到周数
      console.log(daytemp,dayNow,weekNum)
    }
    else{//星期数不同
      //先把星期数转变为相同的星期
      var gap = login_Xingqi-now_Xingqi;//星期数的差
     // console.log(gap)
      dayNow = new Date(dayNow.getTime()+(60*60*24*1000*gap))
      daytemp.setHours(0);
      daytemp.setSeconds(0);
      daytemp.setMinutes(0);
      dayNow.setHours(0);
      dayNow.setSeconds(0);
      dayNow.setMinutes(0);
      //时间戳相减除以七天得到周数
      weekNum = ((dayNow.getTime()-daytemp.getTime())/(7*60*60*24*1000))+1//得到周数
     // console.log(daytemp,dayNow,weekNum)
    }


    //获得星期的数量weekNum之后，给weeks赋值
    var j = weekNum;
    for(var i=0;i<weekNum;i++){
      if(i==0){
        //var now_mondayInt =now_mondayInt -(7*60*60*24*1000)
        j--;
        continue;
      }
      var now_mondayInt = now_mondayInt-(7*60*60*24*1000)
      var now_monday = new Date(now_mondayInt);
      var ymd= this.getDateFormat1(now_monday,3)
     // console.log(j,"这周周一是：",ymd);
      var temp1 = 'weeks['+i+'].monday_date'
      var temp2 = 'weeks['+i+'].week'
      var temp3 = 'weeks['+i+'].state'
      this.setData({
        [temp1]:ymd,
        [temp2]:'第'+j+'周',
        [temp3]:0
      })
      j--;
    }
    //console.log("this.data.weeks:",this.data.weeks)
  
  },

  getmanymonths(){//获取用户使用本小程序到当天有多少个月 并赋值到months中
  //1、获得用户的logindate的年和月
  var logindate=app.globalData.userInfo[0].logindate;
  //var logindate="2021/03/10";
  console.log("用户首次登录的日期：",logindate)
  var loginmonth = parseInt(logindate.substring(5, 7));
  var loginyear = parseInt(logindate.substring(0, 4));
  //console.log(loginyear,loginmonth)
  //2、获得今天的年月
  var dayNow =  new Date()//获取今天的日期 
  var ym = this.getDateFormat1(dayNow,2);
  var temp = 'months['+0+'].yearmonth'
  this.setData({
    [temp]:ym
  })
  //console.log(this.data.months)
  //console.log(year,month)//2021 5
  var month =  dayNow.getMonth()+1//获取月份
  var year = dayNow.getFullYear();//获取年份
  if(year==loginyear&&month==loginmonth){//如果这个月就是用户登录的月份，那么就可以不做操作
  }
  else{//如果这个月不是用户首次登录的对应月份，那么需要知道从这个月到用户登录的那一天之间有多少个月，并赋值到months数组对象中去 赋值格式为"2021年5月"这样子
    var i=1;
    while(year!=loginyear||month!=loginmonth){
      month--;
      if(month==0){year--;month=12}
      //console.log(year,month)
      var y = year+ '/';
      var m = (month < 10 ? '0'+(month) : month);
      var ym1 = y+m;
      var temp1 = 'months['+i+'].yearmonth';
      var temp2 = 'months['+i+'].month'
      var temp3 = 'months['+i+'].state'
      this.setData({
        [temp1]:ym1,
        [temp2]:ym1,
        [temp3]:0
      })
      i++;
    } //console.log(year,month)
   console.log(this.data.months)
  }

  },

  onLoad: function (options) {
    //console.log(app.globalData.userInfo)
    //刚刚加载的时候默认是显示本周的数据图像
    this.getNowWeekData()
    Promise.all(promiseWeek).then(res=>{
      //console.log("完成",this.data.sum);    
      this.getWeekBaifenbi();  
      this.echarCanve = this.selectComponent("#mychart-dom-line");
      this.getOption(this.data.week_xlist,this.data.weeksums);    
       //console.log(this.data.weeksums)
    })
    this.getmanyweeks();//获取用户使用本小程序到当天有多少个周  并赋值到weeks中
    this.getmanymonths();//获取用户使用本小程序到当天有多少个月 并赋值到months中
    //this.getNowMonthData();

  },

  initChart(xlist,ylist){
    //console.log("initChart",xlist,ylist)
     this.echarCanve.init((canvas, width, height)=> {
     const chart = echarts.init(canvas, null, {
       width: width,
       height: height
     });
     this.setOption(chart,xlist,ylist);
     this.chart=chart;
     return chart;
   }) 
  },
  getOption:function(xlist,ylist){
    //console.log("getOption",xlist,ylist)
    this.initChart(xlist,ylist)
  },
  setOption(chart, xlist,ylist) {
    //console.log("setOption",xlist,ylist)
    var option = {
      color: ["#7E80AC"],
      title:{
        text:"折线图"
      },
      tooltip: {
        trigger: 'axis',
        triggerOn: 'click',
        axisPointer: {
          type: "line"
        },
    },
      legend: {
        show:true,
      // data: ['每天总时间','zong']
      },
      grid: {
        left: '5%',
        right: '8%',
        bottom: '10%',
        top:'10%',
        containLabel: true
    },
    
      xAxis: {
        type: 'category',
        boundaryGap: false,
        data: xlist//x轴数据
      },
    
      yAxis: {
        type: 'value',
        splitLine: {
          lineStyle: {
            type: 'solid',
            opacity:0.2
          }
        },
        
      },
      series: [
        {
          name: '总和',
          type: 'line',
          //data: [10,20,30,25,50,45,20],
          data:ylist
        } 
      ]
    };
    //console.log(option.series[0].data)
    chart.setOption(option);
  },

  // 点击周、月选择，两个按钮的颜色互换以及图像的互换和渲染
  clickListener:function(e){
    console.log(e.currentTarget.dataset)
     var nowcolor = e.currentTarget.dataset.bcolor;
     if(nowcolor=="#FFF"){//如果是没有选中的，则颜色的
      if(this.data.b_color1=="#7E80AC"){//确定现在的颜色情况，如果b_color1是蓝色，那么就将蓝色变成白色  
        this.setData({
            b_color1: "#FFF", 
            color1: "#7E80AC",
            b_color2: "#7E80AC",
            color2: "#FFF",
            month_week:0
        })
        this.getNowMonthData()
        Promise.all(promiseMonth).then(res=>{
          this.echarCanve = this.selectComponent("#mychart-dom-line");
          //console.log()
          this.getMonthBaifenbi();  
          this.getOption(this.data.month_xlist,this.data.monthsums);
  
        })   
      }
     //如果b_color1是白色，那么就将它变成蓝色
      else{
        this.setData({
            b_color1: "#7E80AC", 
            color1: "#FFF",
            b_color2: "#FFF",
            color2: "#7E80AC",
            month_week:1,
        })
        this.getNowWeekData()
        Promise.all(promiseWeek).then(res=>{
          // console.log("完成",this.data.sum);
          this.getWeekBaifenbi();        
          this.echarCanve = this.selectComponent("#mychart-dom-line");
          this.getOption(this.data.week_xlist,this.data.weeksums);
        })
       
      }
     } 
    },
  
    // 选择周
  chooseWeekListener:function(e){
  //console.log(e.currentTarget.dataset)
  //得到点击的周的状态,和下标
  var s = e.currentTarget.dataset.state;
  var ind = e.currentTarget.dataset.index;
  //判断点击的周是不是当前显示的周
  if(s==0){//如果不是当前显示的，则跳转成点击的周
    for(var i=0;i<this.data.weeks.length;i++){ //改变样式
      if(i==ind) {
        var temp_state='weeks['+i+'].state';
        this.setData({
          [temp_state]:1
        });
      }
      else{
      var temp_state='weeks['+i+'].state';
      this.setData({
        [temp_state]:0
      });
      }
    }
    //1、获取点击的index,然后再从this.data.weeks中的下标为index的对象中获得这一周的周一日期monday_date。
    var thisMonday_date = this.data.weeks[ind].monday_date;
    var thisMonday_year = parseInt(thisMonday_date.substring(0, 4));
    var thisMonday_month = parseInt(thisMonday_date.substring(5, 7));
    var thisMonday_day = parseInt(thisMonday_date.substring(8, 10));
    //console.log(thisMonday_year,thisMonday_month,thisMonday_day)
    var dayNow = new Date();
    dayNow.setFullYear(thisMonday_year);
    dayNow.setMonth(thisMonday_month-1);
    dayNow.setDate(thisMonday_day);
    var mondayInt = dayNow.getTime();
    //console.log(dayNow)
    //3、之后在将后面的各个星期的对应的日期都赋值上
    for(var i=0;i<7;i++){
      var dayInt = mondayInt+ 24*60*60*1000*i;//往后一天
      var date = new Date(dayInt);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
      var date = this.getDateFormat1(date,3);
      //console.log(date)
      var temp = 'week_date['+i+'].date'
      this.setData({//记录下当天的日期和星期
        [temp]:date
      })
    }
      //console.log(this.data.week_date)
      this.getOneWeekDaySum(this.data.week_date);
      Promise.all(promiseWeek).then(res=>{
        //console.log("完成",this.data.sum);      
        this.getWeekBaifenbi();
        this.echarCanve = this.selectComponent("#mychart-dom-line");
        this.getOption(this.data.week_xlist,this.data.weeksums);
         //console.log(this.data.weeksums)
      })
  }
  },
  
      // 选择月
  chooseMonthListener:function(e){
    console.log(e.currentTarget.dataset)
    //得到点击的周的状态,和下标
    var s = e.currentTarget.dataset.state;
    var ind = e.currentTarget.dataset.index;
    if(s==0){//如果不是当前显示的，则跳转成点击的周
      for(var i=0;i<this.data.months.length;i++){ 
        if(i==ind) {
          var temp_state='months['+i+'].state';
          this.setData({
            [temp_state]:1
          });
          }
          else{
          var temp_state='months['+i+'].state';
          this.setData({
            [temp_state]:0
          });
          }
      }
          //1、获取点击的index,然后再从this.data.weeks中的下标为index的对象中获得这一周的周一日期monday_date。
    var this_year_month = this.data.months[ind].yearmonth;
    var this_year = parseInt(this_year_month.substring(0, 4));
    var this_month = parseInt(this_year_month.substring(5, 7));
    var dayNow = new Date();
    dayNow.setFullYear(this_year);
    dayNow.setMonth(this_month-1);
    dayNow.setDate(1);
    var this_month_firstday = dayNow.getTime();
    console.log(dayNow)
    // 3、判断这个月有多少天 days
    var days=this.getdayNum(this_month,this_year);//获得月份的天数
    for(var i=0;i<days;i++){
      var dayInt = this_month_firstday+ 24*60*60*1000*i;//往后一天
      var date = new Date(dayInt);//时间戳为10位需*1000，时间戳为13位的话不需乘1000
      var date1 = this.getDateFormat1(date,3);
      var date2 = this.getDateFormat1(date,1);
      var temp = 'search_month_date['+i+']';
      var x_month_date = 'month_xlist['+i+']'
      this.setData({
        [temp]:date1,
        [x_month_date]:date2
      })
    }
    this.getOneMonthDaySum(days);
    Promise.all(promiseMonth).then(res=>{
      this.getMonthBaifenbi();
      this.echarCanve = this.selectComponent("#mychart-dom-line");
      //console.log()
      this.getOption(this.data.month_xlist,this.data.monthsums);
    })   
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})